﻿<UserControl x:Class="DaxStudio.UI.Views.FunctionPaneView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro.Platform"
             xmlns:dd="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
             xmlns:conv="clr-namespace:DaxStudio.UI.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" >
    <UserControl.Resources>
        <BitmapImage x:Key="FunctionGroup" UriSource="pack://application:,,,/DaxStudio.UI;component/images/Folder.ico"/>
        <BitmapImage x:Key="Function" UriSource="pack://application:,,,/DaxStudio.UI;component/images/Metadata/Function.png" />
    </UserControl.Resources>
    
    <Grid >
        
        <TreeView Grid.Row="1" x:Name="FunctionGroups" Height="Auto"  ItemsSource="{Binding FunctionGroups}"
                  dd:DragDrop.IsDragSource="True"
                  dd:DragDrop.IsDropTarget="False" 
                  dd:DragDrop.DragHandler="{Binding}"
                  cal:Message.Attach="[Event MouseDoubleClick] = [Action MouseDoubleClick($this.SelectedItem)]"
                  >
            <!--" dd:DragDrop.DragAdornerTemplate="{StaticResource DragAdorner}">>-->
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Functions}">
                    <!-- FunctionGroup Template -->
                    <StackPanel Orientation="Horizontal">
                        <Image Source="{StaticResource FunctionGroup}" Margin="2,1,5,1"/>
                        <TextBlock  Text="{Binding Caption}" />
                    </StackPanel>
                    <!-- Function Template -->
                    <HierarchicalDataTemplate.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" >
                                <Image Source="{StaticResource Function}" Margin="2,1,5,1" />
                                <TextBlock Text="{Binding Caption}"></TextBlock>
                            </StackPanel>
                        </DataTemplate>
                    </HierarchicalDataTemplate.ItemTemplate>
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>

    </Grid>
</UserControl>
